/*
 * @Author: szx
 * @Date: 2022-03-17 12:23:15
 * @LastEditTime: 2022-03-17 13:07:42
 * @Description:
 * @FilePath: \leetcode\剑指offer\10\10.js
 */
/**
 * @param {number} n
 * @return {number}
 */
var fib = function (n) {
    if (n == 0) return 0;
    if (n == 1) return 1;
    let i = 1,
        j = 0;
    let tmp = 0;
    for (let x = 1; x < n; x++) {
        tmp = i;
        i += j;
        j = tmp;
        i %= 1e9 + 7;
    }
    return i;
};
console.log(fib(5));
